package com.total.reporting.presentation;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Util {
	public static String DEFAULT_ENTITY="HD";
	
	
	public static String getDateTimeStr(Date date){
	if( date==null)
		return "";
		String formatStr;
	/*if (Locale.getDefault() == Locale.FRANCE) {
		formatStr = "dd/MM/yy HH:mm";
	} else {
		formatStr = "MM/dd/yy HH:mm";
	}*/
		formatStr = "dd/MM/yy HH:mm";
	DateFormat format = new SimpleDateFormat(formatStr);
	return  format.format(date);

}
	public static String getDateFrStr(Date date){
		if( date==null)
			return "";
			String formatStr = "dd/MM/yyyy";
		DateFormat format = new SimpleDateFormat(formatStr);
		return  format.format(date);

	}
	
	public static Date getDateFromString(String dateStr){
		if( dateStr==null)
			return null;
			String formatStr;
		if ( true || Locale.getDefault() == Locale.FRANCE) {
			formatStr = "dd/MM/yyyy";
		} else {
			formatStr = "MM/dd/yy";
		}
		try{
			DateFormat format = new SimpleDateFormat(formatStr);
			return format.parse(dateStr);
		}
		catch(Exception e){
			return null;
		}

	}
	
	public static String getFloatStr(Float aFloat){
		NumberFormat nf = NumberFormat.getNumberInstance( Locale.FRANCE);
		DecimalFormat df = (DecimalFormat)nf;
		//df.applyPattern(pattern);
		return df.format(aFloat);
	}


}
